﻿<Window x:Class="RunPlusPlus.View.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:sys="clr-namespace:System;assembly=mscorlib"
        xmlns:model="clr-namespace:RunPlusPlus.Model"
        xmlns:local="clr-namespace:RunPlusPlus.View"
        Title="Run ++" Height="550" Width="745" MinHeight="530" MinWidth="680" WindowStartupLocation="CenterScreen" FontSize="14" Background="Transparent">
    <Window.Resources>
        <ObjectDataProvider x:Key="windowTypeEnum" MethodName="GetValues" ObjectType="{x:Type sys:Enum}">
            <ObjectDataProvider.MethodParameters>
                <x:TypeExtension Type="{x:Type model:WindowTypes}"/>
            </ObjectDataProvider.MethodParameters>
        </ObjectDataProvider>
        <local:IsNullBoolConverter x:Key="editPanelConverter"/>
    </Window.Resources>
    <Grid Margin="7">
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"/>
            <RowDefinition/>
        </Grid.RowDefinitions>
        <TextBlock Text="Run ++" Margin="10,5" FontSize="30"/>
        <Grid Grid.Row="1" Margin="5">
            <Grid.Background>
                <SolidColorBrush Color="{DynamicResource {x:Static SystemColors.WindowColorKey}}"/>
            </Grid.Background>
            <Grid.RowDefinitions>
                <RowDefinition/>
                <RowDefinition Height="Auto"/>
            </Grid.RowDefinitions>
            <Grid.ColumnDefinitions>
                <ColumnDefinition/>
                <ColumnDefinition Width="Auto"/>
            </Grid.ColumnDefinitions>
            <ListView Margin="10" ItemsSource="{Binding Shortcuts}" SelectedItem="{Binding SelectedItem}">
                <ListView.View>
                    <GridView>
                        <GridView.Columns>
                            <GridViewColumn Header="Name" Width="100" DisplayMemberBinding="{Binding Name}"/>
                            <GridViewColumn Header="Shortcut" Width="70" DisplayMemberBinding="{Binding Shortcut}"/>
                            <GridViewColumn Header="Target" Width="250" DisplayMemberBinding="{Binding Target}"/>
                            <GridViewColumn Header="Arguments" Width="250" DisplayMemberBinding="{Binding Arguments}"/>
                            <GridViewColumn Header="Startup Path" Width="250" DisplayMemberBinding="{Binding StartupPath}"/>
                            <!--<GridViewColumn Header="Admin" DisplayMemberBinding="{Binding IsRunAsAdministrator}"/>-->
                            <GridViewColumn Header="Window Type" DisplayMemberBinding="{Binding WindowType}"/>
                        </GridView.Columns>
                    </GridView>
                </ListView.View>
            </ListView>
            <StackPanel Grid.Column="1" Margin="5">
                <StackPanel.Resources>
                    <Style TargetType="{x:Type Button}">
                        <Setter Property="Padding" Value="18,7"/>
                        <Setter Property="Margin" Value="5"/>
                    </Style>
                </StackPanel.Resources>
                <Button Content="Add" Command="{Binding AddCommand}"/>
                <Button Content="Remove" Grid.Row="1" Command="{Binding RemoveCommand}"/>
                <Button Content="About" Grid.Row="2" Command="{Binding ShowAboutCommand}"/>
            </StackPanel>
            <GroupBox Header="Edit" Grid.Row="1" Grid.ColumnSpan="2" Margin="10" Padding="5"
                      IsEnabled="{Binding SelectedItem,Converter={StaticResource editPanelConverter}}">
                <Grid>
                    <Grid.Resources>
                        <Style TargetType="{x:Type TextBlock}">
                            <Setter Property="TextAlignment" Value="Right"/>
                            <Setter Property="VerticalAlignment" Value="Center"/>
                            <Setter Property="Margin" Value="3"/>
                        </Style>
                        <Style TargetType="{x:Type TextBox}">
                            <Setter Property="VerticalAlignment" Value="Center"/>
                            <Setter Property="Margin" Value="3"/>
                        </Style>
                    </Grid.Resources>
                    <Grid.RowDefinitions>
                        <RowDefinition/>
                        <RowDefinition/>
                        <RowDefinition/>
                        <RowDefinition/>
                        <RowDefinition/>
                        <RowDefinition/>
                        <RowDefinition/>
                    </Grid.RowDefinitions>
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition/>
                        <ColumnDefinition/>
                    </Grid.ColumnDefinitions>
                    <Grid>
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="Auto"/>
                            <ColumnDefinition />
                        </Grid.ColumnDefinitions>
                        <TextBlock Text="Name"/>
                        <TextBox Grid.Column="1" Text="{Binding SelectedItem.Name, UpdateSourceTrigger=PropertyChanged, Delay=250}"/>
                    </Grid>

                    <Grid Grid.Column="1">
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="Auto"/>
                            <ColumnDefinition />
                        </Grid.ColumnDefinitions>
                        <TextBlock Text="Shortcut"/>
                        <TextBox Grid.Column="1" Text="{Binding SelectedItem.Shortcut, UpdateSourceTrigger=PropertyChanged, Delay=250}"/>
                    </Grid>
                    <Grid Grid.Row="1" Grid.ColumnSpan="2">
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="Auto"/>
                            <ColumnDefinition />
                        </Grid.ColumnDefinitions>
                        <TextBlock Text="Target" />
                        <Grid Grid.Column="1">
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition/>
                                <ColumnDefinition Width="Auto"/>
                            </Grid.ColumnDefinitions>
                            <TextBox x:Name="targetTextBox" Text="{Binding SelectedItem.Target, UpdateSourceTrigger=PropertyChanged, Delay=250}"/>
                            <Button Content="..." Grid.Column="1" Padding="5,0" Margin="0,4,3,4" Click="OnBrowseTargetButtonClick"/>
                        </Grid>
                    </Grid>
                    <Grid Grid.Row="2" Grid.ColumnSpan="2">
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="Auto"/>
                            <ColumnDefinition />
                        </Grid.ColumnDefinitions>
                        <TextBlock Text="Arguments"/>
                        <TextBox Grid.Column="1" Text="{Binding SelectedItem.Arguments, UpdateSourceTrigger=PropertyChanged, Delay=250}"/>
                    </Grid>
                    <Grid Grid.Row="3" Grid.ColumnSpan="2">
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="Auto"/>
                            <ColumnDefinition />
                        </Grid.ColumnDefinitions>
                        <TextBlock Text="Startup Path" />
                        <Grid Grid.Column="1">
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition/>
                                <ColumnDefinition Width="Auto"/>
                            </Grid.ColumnDefinitions>
                            <TextBox x:Name="startupPathTextBox" Text="{Binding SelectedItem.StartupPath, UpdateSourceTrigger=PropertyChanged, Delay=250}"/>
                            <Button Content="..." Grid.Column="1" Padding="5,0" Margin="0,0,3,4" Click="OnBrowseStartupPathButtonClick" Height="21" VerticalAlignment="Bottom"/>
                        </Grid>
                    </Grid>
                    <!--<CheckBox Content="Run as Administrator" IsChecked="{Binding SelectedItem.IsRunAsAdministrator}"
                              VerticalAlignment="Center" Grid.Row="3" Margin="3" />-->
                    <Grid Grid.Row="4" Grid.Column="1">
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="Auto"/>
                            <ColumnDefinition />
                        </Grid.ColumnDefinitions>
                        <TextBlock Text="Window Type"/>
                        <ComboBox ItemsSource="{Binding Source={StaticResource windowTypeEnum}}" SelectedValue="{Binding SelectedItem.WindowType}"
                             Grid.Column="1" Margin="3"/>
                    </Grid>
                    <Button Grid.Row="5" Grid.Column="1" Content="Save" Margin="0,7,0,7"  Padding="30,7" HorizontalAlignment="Right" Command="{Binding SelectedItem.SaveCommand}"/>
                </Grid>
            </GroupBox>
        </Grid>
    </Grid>

</Window>
